package net.muchine.test.ddd.repository.collection;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import net.muchine.test.ddd.Registrar;
import net.muchine.test.ddd.domain.Customer;
import net.muchine.test.ddd.domain.order.Order;
import net.muchine.test.ddd.repository.OrderRepository;

public class CollectionOrderRepository implements OrderRepository {
//	@Autowired private Registrar registrar;
	
	public void save(Order order) {
//		this.registrar.add(Order.class, order);
	}
	
	public Order delete(String orderId) {
		return null;
//		return (Order) this.registrar.delete(Order.class, orderId);
	}

	public Set<Order> findByCustomer(Customer customer) {
		return null;
//		Set<Order> orders = new HashSet<Order>();
//		
//		for (Order order : this.findAll()) {
//			if (order.isOrderedBy(customer)) {
//				orders.add(order);
//			}
//		}
//		
//		return orders;
	}

	@SuppressWarnings("unchecked")
	public Set<Order> findAll() {
		return null;
//		return new HashSet<Order>((Collection<Order>)this.registrar.getAll(Order.class));
	}

	public Order find(String orderId) {
		return null;
//		return (Order) this.registrar.get(Order.class, orderId);
	}
}
